#include "stdafx.h"
#include "LokiFakeUnknown.h"

LokiFakeUnknown::LokiFakeUnknown()
	: _queryInterfaceInputs(),
	_queryInterfaceOutputs(),
	_queryInterfaceOutputCounter(0),
	_addRefOutputs(),
	_addRefOutputCounter(0),
	_releaseOutputs(),
	_releaseOutputCounter(0)
{
}

LokiFakeUnknown::~LokiFakeUnknown()
{
}

HRESULT LokiFakeUnknown::QueryInterface(const IID &riid, void **ppvObj)
{
	QueryInterfaceInputs inputs;
	Loki::Field<0>(inputs) = riid;
	Loki::Field<1>(inputs) = ppvObj;
	_queryInterfaceInputs.push_back(inputs);

	QueryInterfaceOutputs outputs = _queryInterfaceOutputs[_queryInterfaceOutputCounter];
	++_queryInterfaceOutputCounter;
	*ppvObj = Loki::Field<0>(outputs);
	return Loki::Field<1>(outputs);
}

ULONG LokiFakeUnknown::AddRef()
{
	AddRefOutputs outputs = _addRefOutputs[_addRefOutputCounter];
	++_addRefOutputCounter;
	return Loki::Field<0>(outputs);
}

ULONG LokiFakeUnknown::Release()
{
	ReleaseOutputs outputs = _releaseOutputs[_releaseOutputCounter];
	++_releaseOutputCounter;
	return Loki::Field<0>(outputs);
}
